<?php
	
	// OFAC CONF
	$AMLBL = $GLOBALS['MYT']->db_array("SELECT DATE(ablDateUpdate) AS ablDateUpdate, IF(ablDateUpdate<DATE_SUB(CURRENT_DATE, INTERVAL 1 WEEK),1,0) AS NeedsUpdate FROM hd_amlblacklist");
	$OFACV = $GLOBALS['MYT']->db_array("SELECT REF, DATE(sysTime) as sysTime, FileLenght FROM ext_ofac_version ORDER BY REF DESC LIMIT 0,1"); 
	if($AMLBL[1]['NeedsUpdate']==1) {
		$RMTFILE = "http://www.treas.gov/offices/enforcement/ofac/sdn/sdall.zip";
		$fname = date("YmdHis");
		include('cpl_blacklistupdate.php');
	}
	if($AMLBL[1]['ablDateUpdate'] != $OFACV[1]['sysTime']) {
		$AMLBL = $GLOBALS['MYT']->db_array("SELECT ablDateUpdate FROM hd_amlblacklist");
		$FILEID = str_replace('-','',str_replace(':','',str_replace(' ','',$AMLBL[1]['ablDateUpdate'])));
		$EXTFILE = $GLOBALS['DOC']."SEC_OFAC\\".$FILEID.'.zip';
		include('cpl_blacklistupdateloadmodel.php');
	}
	echo 'Done.';